package com.tianhui.consignortwofei.mvp.ui.activity;

import android.widget.TextView;

import com.fgs.common.CommonPresenter;
import com.fgs.common.CommonResponse;
import com.fgs.common.CommonView;
import com.fgs.common.other.CommonEvent;
import com.fgs.common.progress.ExceptionHandle;
import com.fgs.common.progress.ObserverResponseListener;
import com.fgs.common.update.UpdateContext;
import com.fgs.common.utils.LogUtil;
import com.tianhui.consignortwofei.BuildConfig;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.base.BaseActivity;
import com.tianhui.consignortwofei.base.BaseFragment;
import com.tianhui.consignortwofei.mvp.model.UserInfoModel;
import com.tianhui.consignortwofei.mvp.model.enty.YuQiTipInfo;
import com.tianhui.consignortwofei.other.EventWhat;

import org.greenrobot.eventbus.EventBus;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author fgs
 * @date 2020/4/28
 * @description
 **/
public class OverdueManageActivity extends BaseActivity {



    @BindView(R.id.tv_dingdan_text)
    TextView tvDingdanText;
    @BindView(R.id.tv_money_text)
    TextView tvMoneyText;
    @BindView(R.id.tv_day_text)
    TextView tvDayText;
    @BindView(R.id.tv_to_handle)
    TextView tvToHandle;






    UpdateContext updateContext;

    @Override
    public int getLayoutId() {
        return R.layout.activity_overdue_manage;
    }

    @Override
    public CommonPresenter createPresenter() {
        return null;
    }

    @Override
    public CommonView createView() {
        return null;
    }

    @Override
    public void init() {
        setTitle("逾期管理");
        getJiSuanList();
    }

    @Override
    public BaseFragment createFragment() {
        return null;
    }

    @OnClick(R.id.tv_to_handle)
    public void versionUpdate() {
        EventBus.getDefault().post(new CommonEvent(EventWhat.EVENT_MOVE_TO_JISUAN.getValue()));
        finish();
    }


//    @OnClick(R.id.activity_about_downloadTextView)
//    public void download() {
//        String url = AppConfig.apkUrl;
//        Uri uri = Uri.parse(url);
//        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//        startActivity(intent);
//    }



    private void getJiSuanList() {
        UserInfoModel mUserInfoModel = new UserInfoModel();
        Map<String, String> map = new HashMap<>();
//        map.put("limit", "10");
//        map.put("offset", "1");
//        map.put("order", "desc");
//        map.put("sort", "recelvetimeconfirm");
//        map.put("isstatus", "9,12");
//        map.put("page", "1");
//        CommonConfig.getInstance().create(OrderApiService.class).freightList(map);
        mUserInfoModel.getYuQiTipList(getContext(), map, false, this.bindLifecycle(), new ObserverResponseListener<CommonResponse<List<YuQiTipInfo>>>() {
            @Override
            public void onNext(CommonResponse<List<YuQiTipInfo>> commonResponse) {
                if (commonResponse.getCode() == 20000) {
                    List<YuQiTipInfo> dataList = commonResponse.getData();
                    if (dataList != null&& dataList.size() > 0) {
                        YuQiTipInfo yuQiTipInfo = dataList.get(0);
                        if (null!=yuQiTipInfo) {
                            tvDingdanText.setText(yuQiTipInfo.getCounts()+"条");
                            tvMoneyText.setText(yuQiTipInfo.getTradtotalprice()+"元");
                            tvDayText.setText(yuQiTipInfo.getMaxDay()+"天");
                        }
                    }
                } else {
                    LogUtil.print(commonResponse.getMsg());
                }

            }

            @Override
            public void onError(ExceptionHandle.ResponseThrowable e) {
                LogUtil.print(e.message);
            }
        });
    }



}
